package server

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/os/gtime"
	"server-asset/internal/model/entity"
)

// 获取服务器列表请求
type ListServerReq struct {
	g.Meta `path:"/servers" method:"get" tags:"Server" summary:"获取服务器列表"`
}

type ServerCreateInput struct {
	ProjectId  int    `v:"required|min:1#项目必选|项目ID无效"`
	Hostname   string `v:"required|regex:^[a-zA-Z0-9-]+$#主机名必填|只允许字母数字和横线"`
	SshUser    string `v:"required#ssh用户信息必填"`
	SshPort    uint   `v:"required#ssh端口必填"`
	Password   string `v:"required#ssh密码必填"`
	Ip         string `v:"required|ipv4#IP地址必填|IP格式不正确"`
	Cpu        string `v:"required#CPU信息必填"`
	Memory     string `v:"required#内存信息必填"`
	Disk       string `v:"required#磁盘信息必填"`
	DeployInfo string `v:"max-length:1000#部署内容不超过1000字"`
}

type ServerUpdateInput struct {
	Id            int `v:"required#服务器ID必填"`
	Hostname      string
	SshUser       string
	SshPort       uint
	Password      string
	Ip            string `v:"ipv4"`
	Cpu           string
	Memory        string
	Disk          string
	Os            string
	DeployInfo    string
	LastCheckTime gtime.Time
}

type ServerListOutput struct {
	List  []*entity.Server `json:"list"`
	Total int              `json:"total"`
	Page  int              `json:"page"`
	Size  int              `json:"size"`
}

type ServerSimpleInfo struct {
	Id        int    `json:"id"`
	Hostname  string `json:"hostname"`
	IpAddress string `json:"ipAddress"`
}
